﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ComicViewer.IManhua;

namespace ComicViewer
{
    /// <summary>
    /// Interaction logic for PageFunction2.xaml
    /// </summary>
    public partial class BookDetailPage : PageFunction<ComicBook>
    {
        ComicBook m_book;
        public BookDetailPage()
        {
            InitializeComponent();
            m_book = App.Current.Properties["Book"] as ComicBook;
            this.Loaded+=new RoutedEventHandler(BookDetailPage_Loaded);
            
  
        }

        void BookDetailPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (m_book.Tables.Count == 0)
            {
                ListViewTable.ItemsSource = new IManhuaProxy().GetBookTable(m_book);
            }
            else
            {
                ListViewTable.ItemsSource = m_book.Tables;
            }
        }

        protected override void OnReturn(ReturnEventArgs<ComicBook> e)
        {
            base.OnReturn(e);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ComicTable table = (sender as Button).DataContext as ComicTable;
            App.Current.Properties["Table"] = table;
            this.NavigationService.Navigate(new ViewPage2(), table);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new HomePage());
        }
    }
}
